package net.togogo.egouweb1238.core.service.area.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import net.togogo.egouweb1238.common.page.Pagination;
import net.togogo.egouweb1238.core.dao.area.ProvinceDao;
import net.togogo.egouweb1238.core.domain.area.Province;
import net.togogo.egouweb1238.core.query.area.ProvinceQuery;
import net.togogo.egouweb1238.core.service.area.IProvinceService;
/**
 * 省
 * @author stone
 */
@Service
@Transactional
public class ProvinceServiceImpl implements IProvinceService {

	@Resource
	private ProvinceDao provinceDao;

	/**
	 * 插入数据库
	 * 
	 * @return
	 */
	public Integer addProvince(Province province) {
		return provinceDao.addProvince(province);
	}

	/**
	 * 根据主键查找
	 */
	@Transactional(readOnly = true)
	public Province getProvinceById(Integer id) {
		return provinceDao.getProvinceById(id);
	}
	
	@Transactional(readOnly = true)
	public List<Province> getProvincesByIds(List<Integer> idList) {
		return provinceDao.getProvincesByIds(idList);
	}

	/**
	 * 根据主键删除
	 * 
	 * @return
	 */
	public Integer deleteById(Integer id) {
		return provinceDao.deleteById(id);
	}

	public Integer deleteByIds(List<Integer> idList) {
		return provinceDao.deleteByIds(idList);
	}

	/**
	 * 根据主键更新
	 * 
	 * @return
	 */
	public Integer updateProvinceById(Province province) {
		return provinceDao.updateProvinceById(province);
	}
	
	@Transactional(readOnly = true)
	public Pagination getProvinceListWithPage(ProvinceQuery provinceQuery) {
		Pagination p = new Pagination(provinceQuery.getPageNo(),provinceQuery.getPageSize(),provinceDao.getProvinceListCount(provinceQuery));
		p.setList(provinceDao.getProvinceListWithPage(provinceQuery));
		return p;
	}
	
	@Transactional(readOnly = true)
	public List<Province> getProvinceList(ProvinceQuery provinceQuery) {
		return provinceDao.getProvinceList(provinceQuery);
	}
}
